package com.leyou.search.entity;

import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.persistence.Id;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.Set;

/**
 * indexName:索引库
 * type:映射类型
 * shards:分片
 * replicas:备份
 */
@Data   //提供get/set方法
@Document(indexName = "goods",type = "docs",shards = 1,replicas = 0)
public class Goods {
    /**
     * 要展示的字段
     */
    //spu的id
    @Id
    @Field(type = FieldType.Keyword)
    private Long id;
    //spu的副标题
    @Field(type = FieldType.Keyword,index = false)
    private String subTitle;
    //sku的集合的json字符串:为了不让elasticsearch对skus集合进行分词,而是作为一个整体返回
    @Field(type = FieldType.Keyword,index = false)
    private String skus;


    /**
     * 要过滤的字段
     */
    //要搜索的所有字段的组合字符串(匹配搜索框内搜索的内容)
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String all;
    //分类id(三级分类)
    private Long categoryId;
    //品牌id
    private Long brandId;
    //规格参数的key和value
    private Map<String, Object> specs;
    //所有sku的价格的集合(滤重)
    private Set<Long> price;
    //spu创建的时间
    private Long createTime;
}
